<template>
  <!-- hidden PageHeaderWrapper title demo -->
  <page-header-wrapper :title="false" content="新建文章">
    <a-card :body-style="{padding: '10px 15px'}" :bordered="false">
      <blog-article
        :article="article"
        :loading="loading"
        @submit="saveArticle"
      >
      </blog-article>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import BlogArticle from '@/components/Blog/BlogArticle.vue'
import { newArticle } from '@/api/blog'
export default {
  name: 'ArticleNew',
  components: { BlogArticle },
  component: {
    BlogArticle
  },
  data () {
    return {
      loading: false,
      article: {}
    }
  },
  computed: {

  },
  mounted () {

  },
  methods: {
    // handler
    saveArticle (data, e) {
      e.preventDefault()
      this.loading = true
      newArticle(data).then(res => {
        this.loading = false
        this.$message.success('Saved OK!')
        this.$router.push({ name: 'BlogArticleList' })
      }).catch(err => {
        this.$message.error(err)
      })
    }
  }
}
</script>
